package com.iss.card.view.account;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.iss.card.R;
import com.iss.card.common.CommonValue;
import com.iss.card.common.FunctionUtil;

public class AccountAboutFargment extends Fragment {
	private Activity mContext;

	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);

		this.mContext = activity;
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {

		LinearLayout layout = (LinearLayout) inflater.inflate(
				R.layout.about_layout, null);
		initAboutUs(layout);
		return layout;
	}

	private void initAboutUs(LinearLayout layout) {
		TextView mJobName = (TextView) layout.findViewById(R.id.job_name_val);
		mJobName.setText(R.string.about_su);

		Button mReturnBut = (Button) layout.findViewById(R.id.return_button);
		mReturnBut.setBackgroundResource(R.drawable.return_selector);
		mReturnBut.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				mContext.finish();
			}
		});
		mReturnBut.setVisibility(View.VISIBLE);

		TextView version = (TextView) layout
				.findViewById(R.id.tv_about_us_version);
		version.setText(String.format(
				getResources().getString(R.string.about_version),
				CommonValue.APP_VERSION));

		TextView copyRight = (TextView) layout
				.findViewById(R.id.tv_about_us_copyright_year);
		final int curYear = FunctionUtil.getCurrentYear();
		copyRight.setText(String
				.format(getResources().getString(R.string.about_copyright_day),
						curYear <= CommonValue.COPYRIGHT_YEAR_START ? CommonValue.COPYRIGHT_YEAR_START
								: (CommonValue.COPYRIGHT_YEAR_START + "-" + curYear)));
	}
}